#include<iostream>
using namespace std;
int main()
{
	int year, month1, day;
	while (scanf_s("%d/%d/%d", &year, &month1, &day) != EOF)
	{
		if (year % 400 == 0 || year % 4 == 0 && year % 100 != 0)
		{
			int month[13] = { 0,31,29,31,30,31,30,31,31,30,31,30,31 };
			int sum = 0;
			for (int i = 1; i <= month1; i++)
			{
				sum += month[i - 1];
			}
			cout << sum + day << endl;
		}
		else
		{
			int month[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
			int sum = 0;
			for (int i = 1; i <= month1; i++)
			{
				sum += month[i - 1];
			}
			cout << sum + day << endl;
		}
	}
	return 0;
}